﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Web.Http;
using System.Web.Http.Routing;
using System.Web.Http.Dispatcher;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.IO;
using System.Configuration;
using System.ServiceModel;
using Microsoft.Owin.Hosting;

namespace WebApiSelfByWindowsService
{
    public partial class MonitorNetService : ServiceBase
    {
        public MonitorNetService()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            Logger.Info("检测网上报接口服务开始启动...");
            try
            {
                Logger.Info("正在监听8083端口");
                WebApp.Start<Startup>("http://localhost:8083");
                Logger.Info("检测网上报接口服务启动成功！");
            }
            catch (Exception ex)
            {

                Logger.Fatal("检测网上报接口服务启动失败！\t\n" + ex.ToString());
            }
        }

        protected override void OnStop()
        {
            Logger.Info("检测网上报接口服务已停止！");
        }
    }
}
